<script src="js/Calendar.js" type="text/javascript"></script>
<script type="text/javascript" src="js/global/Date_func.js"></script>
<link rel="stylesheet" type="text/css" href="css/member.css"/>
<style>
	.report{margin:10px 0; padding:15px; border:1px solid #eee}
	.report span.part{ margin-right:20px;}
	input.time{    background: url("images/rili.png") no-repeat scroll right center #FFFFFF;
    border: 1px solid #7F9DB9;
    height: 20px;
    line-height: 20px;
    width: 120px;}
	.total{ width:100%; text-align:center;}
	input.checkbox{ vertical-align:-2px; margin-right:2px;}
	.btn{ background:#eee; padding:4px 15px; *padding:4px 8px; background:url("images/mc_title.png") no-repeat right top; color:#fff; border:none; cursor:pointer}
	#excel{margin-left:10px;}
</style>
<h3 class="mc_title">
	<span class="mctit_1 <?=($from!="sale")?"notcur":""?>">
		<a href="orderReport_dt.html"><span class="mctit_2">销售报表</span></a>
	</span>
	<?if($_a->checkAuth("buyOrderReport.html")){?>
	<span class="mctit_1 <?=($from=="sale")?"notcur":""?>">
		<a href="buyOrderReport_dt.html"><span class="mctit_2">购买报表</span></a>
	</span>
	<?}?>
</h3>
<form class="report">
	<input type="hidden" name="act" id="act" value=""/>
	<p>
		<span class="part">
			<label>
                <!--交易日期：-->
                <select name="time_type" id="time_type">
                    <option value="1" <?=$_REQUEST['time_type']==1?'selected' :''?>>下单时间</option>
                    <option value="2" <?=$_REQUEST['time_type']==2?'selected' :''?>>预计游玩</option>
                    <option value="3" <?=$_REQUEST['time_type']==3?'selected' :''?>>完成时间</option>
                </select>
            </label>
			<input type="text" name="begintime" id="begintime" class="time" value="<?=$btime?>" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)"/>
			<label>至</label>
			<input type="text" name="endtime" id="endtime" class="time" value="<?=$etime?>" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)"/>
			<!--
			<select id="time">
				<option>选择</option>
				<option value="today" <?=$_REQUEST['timeT']=="today"?"selected":""?>>今天</option>
				<option value="yesterday" <?=$_REQUEST['timeT']=="yesterday"?"selected":""?>>昨天</option>
				<option value="week" <?=$_REQUEST['timeT']=="week"?"selected":""?>>本周</option>
				<option value="lastweek" <?=$_REQUEST['timeT']=="lastweek"?"selected":""?>>上周</option>
				<option value="month" <?=$_REQUEST['timeT']=="month"?"selected":""?>>本月</option>
				<option value="lastmonth" <?=$_REQUEST['timeT']=="lastmonth"?"selected":""?>>上月</option>
			</select>
			-->
			<a href="javascript:void(0);" class="sDate">今天</a>
			<a href="javascript:void(0);" class="sDate">昨天</a>
			<a href="javascript:void(0);" class="sDate">本周</a>
			<a href="javascript:void(0);" class="sDate">上周</a>
			<a href="javascript:void(0);" class="sDate">本月</a>
			<a href="javascript:void(0);" class="sDate">上月</a>
		</span>
		<!--<span  class="part">
			<input class="checkbox" type="checkbox" name="status[]" <?=in_array("0|6",$_REQUEST['status'])?"checked":""?> value="0|6"/><label>未使用</label>
			<input class="checkbox" type="checkbox" name="status[]" <?=in_array("1",$_REQUEST['status'])?"checked":""?> value="1"/><label>已使用</label>
			<input class="checkbox" type="checkbox" name="status[]" <?=in_array("2",$_REQUEST['status'])?"checked":""?> value="2"/><label>已过期</label>
			<input class="checkbox" type="checkbox" name="status[]" <?=in_array("3|5",$_REQUEST['status'])?"checked":""?> value="3|5"/><label>已取消</label>
		</span>
		<!--<span  class="part">-->
			<!--<select name="by">-->
				<!--<option value="">统计方式</option>-->
				<!--<option value="lid" <?=($_REQUEST['by']=="lid")?"selected":""?>>按景区统计</option>-->
				<!--<option value="tid" <?=($_REQUEST['by']=="tid")?"selected":""?>>按门票统计</option>-->
				<!--<option value="mid" <?=($_REQUEST['by']=="mid")?"selected":""?>>按分销商统计</option>-->
			<!--</select>-->
		<!--</span>-->
		
		<input type="submit" class="btn" value="查 询"/>
		<input type="button" id="excel" class="btn" value="导 出"/>
	</p>
<p style="margin:10px 0;">
	订单状态：
	<span  class="part">
		<input class="checkbox" type="checkbox" name="status[]" <?=in_array("0|6",$_REQUEST['status'])?"checked":""?> value=""/><label>全部</label>
		<input class="checkbox" type="checkbox" name="status[]" <?=in_array("0|6",$_REQUEST['status'])?"checked":""?> value="0|6"/><label>未使用</label>
		<input class="checkbox" type="checkbox" name="status[]" <?=in_array("1",$_REQUEST['status'])?"checked":""?> value="1"/><label>已使用</label>
		<input class="checkbox" type="checkbox" name="status[]" <?=in_array("2",$_REQUEST['status'])?"checked":""?> value="2"/><label>已过期</label>
		<input class="checkbox" type="checkbox" name="status[]" <?=in_array("3|5",$_REQUEST['status'])?"checked":""?> value="3|5"/><label>已取消</label>
	</span>
	</p>
    <p style="margin:10px 0;">
        <?if(isset($DistorsNames) && count($DistorsNames)>0):?>
            <span  class="part">
            分销商:<?=GetHtmlSelect($DistorsNames, 'fid', $fid, array('k'=>0,'v'=>'--分销商--'))?>
            </span>
       <?endif;?>
        <span  class="part">
            景点：
            <select name="by">
                <option value="">--选择--</option>
                <option value="lid" <?=($_REQUEST['by']=="lid")?"selected":""?>>按景区统计</option>
                <option value="tid" <?=($_REQUEST['by']=="tid")?"selected":""?>>按门票统计</option>
                <option value="mid" <?=($_REQUEST['by']=="mid")?"selected":""?>>按分销商统计</option>
            </select>
        </span>
		<span  class="part">
            门票：
            <select name="by">
                <option value="">--选择--</option>
                <option value="lid" <?=($_REQUEST['by']=="lid")?"selected":""?>>按景区统计</option>
                <option value="tid" <?=($_REQUEST['by']=="tid")?"selected":""?>>按门票统计</option>
                <option value="mid" <?=($_REQUEST['by']=="mid")?"selected":""?>>按分销商统计</option>
            </select>
        </span>
    </p>

</form>
<div class="rank">
	<div class="rankcon">
		<table class="ranktab">
			<thead id="rankhd">
				<th>序号</th>
				<th class="tL"><?=$titleT[$by]?></th>
				<th><span class="sort" onclick="sortTable('offmain',2, true ,this);">订单数</span></th>
				<th><span class="sort" onclick="sortTable('offmain',3, true ,this);">门票数</span></th>
				<th><span class="sort" onclick="sortTable('offmain',4, true ,this);">总金额</span></th>
				<th><span class="sort" onclick="sortTable('offmain',5, true ,this);">在线支付</span></th>
				<th><span class="sort" onclick="sortTable('offmain',6, true ,this);">余额支付</span></th>
				<th><span class="sort" onclick="sortTable('offmain',7, true ,this);">授信支付</span></th>
				<th><span class="sort" onclick="sortTable('offmain',8, true ,this);">现场到付</span></th>
			</thead>
			<tbody id="offmain">
				<?foreach($r as $lid=>$row){
					$totals['order']+=$row['order'];
					$totals['tnum']+=$row['tnum'];
					$totals['money']+=$row['money']/100;
					$totals['pmode0']+=$row['pmode0']/100;
					$totals['pmode1']+=$row['pmode1']/100;
					$totals['pmode2']+=$row['pmode2']/100;
					$totals['pmode3']+=$row['pmode3']/100;
				?>
				<tr>
					<td><?=++$n?></td>
					<td class="tL"><?=$row['title']?></td>
					<td><?=$row['order']?></td>
					<td><?=$row['tnum']?></td>
					<td><?=$row['money']/100?></td>
					<td><?=$row['pmode0']/100?></td>
					<td><?=$row['pmode1']/100?></td>
					<td><?=$row['pmode2']/100?></td>
					<td><?=$row['pmode3']/100?></td>
				</tr>
				<?}?>
			</tbody>
			<tfoot>
			<?if(count($r)>0){?>
				<tr>
					<td  colspan="2">总计：</td>
					<td><?=$totals['order']?></td>
					<td><?=$totals['tnum']?></td>
					<td><?=$totals['money']?></td>
					<td><?=$totals['pmode0']?></td>
					<td><?=$totals['pmode1']?></td>
					<td><?=$totals['pmode2']?></td>
					<td><?=$totals['pmode3']?></td>
				</tr>
			<?}else{?>
				<tr>
					<td align="left" colspan="9">&nbsp;&nbsp;&nbsp;交易日期无销售订单！</td>
				</tr>
			<?}?>
			</thead>
		</table>
	</div>
</div>
<script src="js/jsorder.js"></script>
<script src="js/jsorder.js"></script>
<script>
	$("#time").change(function(){
		Date_func.selectDate($(this).val(),$("#begintime").get(0),$("#endtime").get(0));
	});
	$("input.btn").click(function(){
		var btime=$("#begintime").val();
		var etime=$("#endtime").val();
		btime=btime.split("-");
		etime=etime.split("-");
		month=(etime[0]-btime[0])*12+(etime[1]-btime[1]);
		if(month>3){
			alert("交易日期时间间隔不能超过三个月");
			return false;
		}
	});
	$("#excel").click(function(){
		$("#act").val("orderReportExcel");
		$("form.report").submit();
		$("#act").val("");
	});
</script>